//Card Class

#include <iostream>
#include "card.h"

using namespace std;

Card::Card(){
	suit = HEART;
	value = 2;
}

Card::Card(int val, int suitNum){
	/*if(value >=2 && value <= 14)*/
		value = val;
	//else
	//	throw InvalidValueException();
	
	switch(suitNum){
		case 1: suit = HEART;
			break;
		case 2: suit = DIAMOND;
			break;
		case 3: suit = CLUB;
			break;
		case 4: suit = SPADE;
			break;
		/*default:
			throw InvalidSuitException();*/
	}
}

void Card::setVal(int val){
	if (value > 1 || value < 15)
		value = val;
	//else
	//	throw InvalidValueException();
}

void Card::setSuit(Suit newSuit){
	suit = newSuit;
}

void Card::setSuit(int newSuit){
		switch(newSuit){
		case 1: suit = HEART;
			break;
		case 2: suit = DIAMOND;
			break;
		case 3: suit = CLUB;
			break;
		default: suit = SPADE;
		/*default:
			throw InvalidSuitException();*/
	}
}

bool Card::operator== (Card rhs){
	if (suit == rhs.suit && value == rhs.value)
		return true;
	else
		return false;
}

bool Card::operator<(Card rhs){
	if (value < rhs.value)
		return true;
	else
		return false;
}

ostream& operator<<(ostream& out, Card card) {
	if(card.value < 10) {	
		out << card.value;
	}
	else{
		switch(card.value){
			case 10:
				out << "T";
				break;
			case 11: 
				out << "J";
				break;
			case 12:
				out << "Q";
				break;
			case 13:
				out << "K";
				break;
			default: 
				out << "A";
		}
	}
			
	switch(card.suit){
		case HEART: 
			out << '\3';
			break;
		case DIAMOND: 
			out << '\4';
			break;
		case CLUB: 
			out << '\5';
			break;
		default: 
			out << '\6';
	}

	return out;
	
}
